<?php
class TimeUtil {
	const OND_DAY = 86400;
	const SEVEN_DAY = 604800;
	const THIRTY_DAY = 2592000;
	static function format($time){
        $now = time();
        $offset = $now - $time;
        if ($offset >= self::THIRTY_DAY) {
        	return intval($offset/self::THIRTY_DAY)."月";
        }
        if ($offset >= self::SEVEN_DAY) {
        	return intval($offset/self::SEVEN_DAY)."周";
        }
        if ($offset >= self::OND_DAY) {
        	return intval($offset/self::OND_DAY)."天";
        }
        if ($offset >= 3600) {
        	return intval($offset/3600)."小时";
        }
        if ($offset >= 60) {
        	return intval($offset/60)."分钟";
        }
        return $offset."秒";
	}
}
?>